﻿using NicoViewLib.Model;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace NicoView_Lib_UnitTest
{
    [TestFixture]
    class NicoView_LibRegexTest
    {

        private static Regex _noAnchorRegex = new Regex(NicoFormat.NOANCHOR_FORMAT);

        private static Regex _liveIdRegex = new Regex(NicoFormat.LIVEID_FORMAT);

        private static Regex _videoIdRegex = new Regex(NicoFormat.VIDEOID_FORMAT);

        private static Regex _htmlRegex = new Regex(NicoFormat.HTML_TAG);



        [TestCase(">>2",">>2")]
        [TestCase(">>20", ">>20")]
        [TestCase(">>99", ">>99")]
        [TestCase(">>100テストメッセージ", ">>100")]
        [TestCase("テストメッセージ>>100テストメッセージ", ">>100")]
        [TestCase(">>99-20", ">>99-20")]
        [TestCase(">>100-101", ">>100-101")]
        public void NoAnchorTest(string target,string rslt)
        {
            
            Assert.AreEqual(rslt,_noAnchorRegex.Match(target).Value);
        }

        [TestCase(">>100-101", ">>100-")]
        public void NoAnchorTestEgnoreCase(string target, string rslt)
        {
            Assert.AreNotEqual(rslt, _noAnchorRegex.Match(target).Value);
        }

        [TestCase("lv25546","lv25546")]
        [TestCase("lv00000", "lv00000")]
        [TestCase("lv99999", "lv99999")]
        [TestCase("testLiveMessage:lv25546", "lv25546")]
        public void LiveIdTest(string target, string rslt)
        {
            Assert.AreEqual(rslt, _liveIdRegex.Match(target).Value);
        }

        [TestCase("co5224466","co5224466")]
        [TestCase("ch5224466", "ch5224466")]
        [TestCase("nm5224466", "nm5224466")]
        [TestCase("sm5224466", "sm5224466")]
        [TestCase("lvAAAAAA", "lvAAAAAA")]
        [TestCase("lvB00000", "lvB00000")]
        [TestCase(">>100-101", ">>100-101")]
        public void LiveIdTestEgnoreCase(string target, string rslt)
        {
            Assert.AreNotEqual(rslt, _liveIdRegex.Match(target).Value);
        }

        [TestCase("nm25547989", "nm25547989")]
        [TestCase("sm25547989", "sm25547989")]
        public void VideoIdTest(string target, string rslt)
        {
            Assert.AreEqual(rslt, _videoIdRegex.Match(target).Value);
        }

        [TestCase("nm25547989","nm2554798")]
        [TestCase("lv99999", "lv99999")]
        public void VideoIdTestEgnoreCase(string target, string rslt)
        {
            Assert.AreNotEqual(rslt, _videoIdRegex.Match(target).Value);
        }


        [TestCase("<test>","<test>")]
        [TestCase("</test>","</test>")]
        public void HtmlTest(string target, string rslt)
        {
            Assert.AreEqual(rslt, _htmlRegex.Match(target).Value);
        }


        [TestCase("<test","<test")]
        public void HtmlTestEgnoreCase(string target, string rslt)
        {

        }
    }
}
